1 00:00:00,300 --> 00:00:06,400 So to do our server side purchasing, let's go to our shop and use that script. 2 00:00:06,420 --> 00:00:12,480 So if I go up here, I got my shop, opened that up, and then I have this activate shop script. 3 00:00:13,050 --> 00:00:14,490 That's where we open it up. 4 00:00:14,490 --> 00:00:18,930 But it's really convenient because we have replicated storage, We have our shop. 5 00:00:18,930 --> 00:00:25,680 Ray and I need to catch the event coming from the client, from the shop. 6 00:00:25,680 --> 00:00:34,920 Ray So notice we sent the request to open the shop up on this side and then we use the same remote event 7 00:00:34,920 --> 00:00:38,010 to capture the sale coming back, right? 8 00:00:38,010 --> 00:00:39,480 The server side event. 9 00:00:39,480 --> 00:00:40,680 That's kind of convenient. 10 00:00:40,680 --> 00:00:42,900 You could use remote events over and over. 11 00:00:42,900 --> 00:00:45,720 If you were really clever, you'd only need one. 12 00:00:45,720 --> 00:00:47,490 But I'm not that clever. 13 00:00:47,490 --> 00:00:53,210 I like to make remote events and name them specifically for their things that I keep track of. 14 00:00:53,220 --> 00:00:54,240 I'm a little easier. 15 00:00:54,660 --> 00:00:58,500 I'm going to do the shop re dot on server event. 16 00:00:58,500 --> 00:01:05,820 So when that when that when we capture that event, we are going to connect to an anonymous function. 17 00:01:05,820 --> 00:01:07,980 We will get the player first. 18 00:01:07,980 --> 00:01:12,600 So in a client sends a remote event, player always comes first. 19 00:01:12,600 --> 00:01:20,520 If you remember we just sent the item name and the item price, so I'll get my item name and the item 20 00:01:20,520 --> 00:01:22,830 price after the player. 21 00:01:23,430 --> 00:01:27,780 A lot of people do the remote events and they are looking for like the name here and they're getting 22 00:01:27,780 --> 00:01:30,560 the player and they're getting an error and it's kind of weird. 23 00:01:30,570 --> 00:01:32,190 They don't know why, but that's it. 24 00:01:32,190 --> 00:01:37,350 The player is always going to be first, so let's get the item with the item name. 25 00:01:37,350 --> 00:01:38,910 We have replicated storage. 26 00:01:38,910 --> 00:01:41,430 We declared it above Wait for child. 27 00:01:41,430 --> 00:01:49,050 Remember, we have our simple pistol and our fabulous lemon inside replicated storage we will look for. 28 00:01:49,050 --> 00:01:51,720 Also have to do is put item name in there. 29 00:01:51,720 --> 00:01:55,800 It should either be simple pistol or fabulous lemon. 30 00:01:55,800 --> 00:02:01,230 Right now let's check to see if we actually got the item. 31 00:02:01,230 --> 00:02:04,440 If item, then we will clone the item. 32 00:02:04,440 --> 00:02:12,540 I'll call it item clone item, Colon, clone Aereo. 33 00:02:12,540 --> 00:02:16,830 And then let's put the item clone 34 00:02:18,900 --> 00:02:22,350 parent equal to our players backpack. 35 00:02:22,350 --> 00:02:26,190 So that essentially puts the item in the backpack. 36 00:02:26,280 --> 00:02:26,720 All right. 37 00:02:26,760 --> 00:02:31,890 And now this is where we subtract our points from our leaderboard from our leader stats. 38 00:02:31,890 --> 00:02:37,220 So let's get a value for that price because it's coming over as text. 39 00:02:37,230 --> 00:02:41,460 I'm going to do a two number and then what do we call it? 40 00:02:42,120 --> 00:02:43,410 Item price. 41 00:02:44,700 --> 00:02:46,230 Item price. 42 00:02:47,100 --> 00:02:51,000 And we can do a little bit of a check for security. 43 00:02:51,420 --> 00:02:55,830 You should you should you should actually check the price on this side. 44 00:02:55,830 --> 00:02:57,930 But what I'm going to do is I'm just going to do an F statement. 45 00:02:57,930 --> 00:03:10,140 I do if price is less than or equal to our highest priced item, which is 2000 and price is greater 46 00:03:10,140 --> 00:03:15,720 than or equal to 1000, which is our lowest priced item, then we'll make the purchase. 47 00:03:15,720 --> 00:03:19,320 So they could still hack the system, but they're not going to get that much from it. 48 00:03:19,320 --> 00:03:27,930 So let's say player leader stats, dot points, dot value. 49 00:03:29,660 --> 00:03:34,120 Minus equals price to have a price. 50 00:03:34,130 --> 00:03:34,550 There we go. 51 00:03:34,550 --> 00:03:35,360 Price. 52 00:03:37,370 --> 00:03:40,760 All right, let's try this out so you don't even need this. 53 00:03:40,760 --> 00:03:42,170 If statement will work without it. 54 00:03:42,170 --> 00:03:42,560 It's just. 55 00:03:42,560 --> 00:03:45,230 This is just a check in case someone hacks your game. 56 00:03:45,800 --> 00:03:47,510 They don't give themselves a million. 57 00:03:47,510 --> 00:03:49,250 A million points. 58 00:03:50,750 --> 00:03:54,500 We'll go to output window check for errors. 59 00:03:54,500 --> 00:03:57,920 Should we squish this up so that our window looks pretty good? 60 00:04:00,090 --> 00:04:01,110 Here we go. 61 00:04:01,200 --> 00:04:02,970 Simple pistol. 62 00:04:04,280 --> 00:04:05,210 Bye. 63 00:04:05,390 --> 00:04:05,900 All right. 64 00:04:05,900 --> 00:04:07,580 So it subtracted our points. 65 00:04:07,610 --> 00:04:09,200 Not enough money. 66 00:04:09,200 --> 00:04:10,630 Oh, my goodness. 67 00:04:10,640 --> 00:04:12,320 So I've got to go get some money. 68 00:04:12,320 --> 00:04:13,850 I'm going to pause the video. 69 00:04:16,630 --> 00:04:17,620 Okay, I'm back. 70 00:04:17,620 --> 00:04:19,270 I didn't actually get coins. 71 00:04:19,270 --> 00:04:23,020 I went in the game manager gave myself some some extra money. 72 00:04:23,020 --> 00:04:26,500 So let's go and click our little bell. 73 00:04:27,070 --> 00:04:28,530 Simple pistol. 74 00:04:28,540 --> 00:04:30,580 Oh, let's look at our output window. 75 00:04:31,870 --> 00:04:34,780 And then let's make our windows so that it doesn't look weird. 76 00:04:35,110 --> 00:04:36,640 They're going to hit by. 77 00:04:37,710 --> 00:04:38,840 There we go. 78 00:04:38,850 --> 00:04:40,010 We got a pistol. 79 00:04:40,020 --> 00:04:41,970 We should clear this out, though. 80 00:04:42,000 --> 00:04:48,600 We should also check to make sure not to do double purchases, because right now we don't have a cell 81 00:04:48,630 --> 00:04:49,330 back. 82 00:04:49,350 --> 00:04:51,300 We'll have to work on that at some point. 83 00:04:51,300 --> 00:04:54,180 So then I have my fabulous lemon. 84 00:04:54,180 --> 00:04:56,730 That's 2000 points. 85 00:04:57,630 --> 00:04:59,520 Oh, not enough money. 86 00:04:59,520 --> 00:05:06,330 And we have to get our queuing service to put something up saying we don't have enough money yet, but 87 00:05:06,330 --> 00:05:09,990 we basically have a functioning store. 88 00:05:10,620 --> 00:05:10,840 All right. 89 00:05:10,860 --> 00:05:11,550 So there you go. 90 00:05:11,550 --> 00:05:13,860 That's the minimum requirement for a store. 91 00:05:14,400 --> 00:05:14,790 All right. 92 00:05:14,790 --> 00:05:16,380 I will see you in the next video. 93 00:05:16,380 --> 00:05:18,300 We'll do a little bit of cleanup of this.